/**
 * @class   wosh::interfaces::services::Discovery
 * @brief   Standard interface of Discovery (service).
 *
 *
 *
 * @par Generic Announcement Flow
 *  Each discovery service (independently) announce the some information about
 *  localhost to the network (using its own protocol and channel specifications),
 *  usually the procedure works only if the same service is installed on both (all) hosts.
 *  WOSH networking architecture also provides (partially) multi-hop discovery,
 *  but it is enabled and maintained by wosh::NetworkManager.
 *
 * \msc
Discovery_Network, Discovery_Service, NetworkManager;
--- [ label=" Periodic routine (and on explicit request) "];
Discovery_Service=>NetworkManager [ label="retrieve local-host info", URL="\ref wosh::NetworkManager::getLocalWoshHost()" ];
Discovery_Service<-NetworkManager [ label="copy of wosh::WoshHost", URL="\ref wosh::WoshHost" ];
Discovery_Service=>Discovery_Service [ label="build custom data from WoshHost" ];
Discovery_Service=>Discovery_Network [ label="announce local-host", URL="\ref wosh::interfaces::services::Discovery::doAnnounceLocalHost()" ];
 * \endmsc
 *
 * @par Discovery of remote-hosts Flow
 *  Someway the discovery service is notified of the presence of another WOSH host.
 *  The incoming announcement data also contains information about the host, in order to
 *  enable automatic configuration and connection (handled by wosh::NetworkManager).
 *  The role of Discovery service is to convert the notification as wosh::Host object and 
 *  forward it to wosh::NetworkManager core-module.
 *
 * \msc
Discovery_Network, Discovery_Service, NetworkManager;
--- [ label=" (asynch) notification of a remove host"];
Discovery_Network=>Discovery_Service [ label="incoming announcement" ];
Discovery_Service=>Discovery_Service [ label="extract WoshHost info from my custom protocol", URL="\ref wosh::WoshHost" ];
Discovery_Service=>NetworkManager [ label="forward updated host data", URL="\ref wosh::NetworkManager::updateWoshHost()" ];
 * \endmsc
 *
 * @see     \ref page_core_network, wosh::NetworkManager
 * @see     wosh::interfaces::services::DiscoveryUdp
 * @see     wosh::services::DiscoveryUdpBundle
 * @ingroup Interfaces
 ****************************************************************************
 * @version 0.8.499 $Id: Discovery.h 2289 2010-04-09 09:14:03Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Interfaces_Services_Discovery_H__
 #define __WOSH_Interfaces_Services_Discovery_H__

 #include <interfaces/Service.h>


namespace wosh {
 namespace interfaces {
  namespace services {

/**
 * @def    _Discovery_KEY_NotifyFrequency
 * @brief  Property: the interval between each notification in seconds. Type: INT
 */
 #define _Discovery_KEY_NotifyFrequency			"NotifyFrequency"

/**
 * @def    _Discovery_METHOD_discover
 * @brief  Method: force a discovery of remote hosts (announce myself on the network)
 */
 #define _Discovery_METHOD_discover				"discover"


class Discovery : public virtual Service
 {
	WOSH_BUNDLE_INTERFACE("wosh::interfaces::services::Discovery")


/** @name Discovery Interface
 * @{
 ******************************************************************************/
	public:
		/**
		 * @brief  Start the discovery procedure of remote WOSH hosts.
		 *         Announcement may be synchronous or asynchronous,
		 *         but the discovery procedure is intrinsically asynchronous.
		 * @return custom error codes; WRET_OK on success
		 * @see    wosh::NetworkManager::getLocalWoshHost()
		 * @see    wosh::NetworkManager::updateWoshHost()
		 */
		virtual WRESULT doAnnounceLocalHost() = 0;

//@}
	public:
		virtual ~Discovery() { }

}; // class def

  }; // namespace services
 }; // namespace interfaces
}; // namespace wosh

#endif //__WOSH_Interfaces_Services_Discovery_H__
